﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using SHJunketingModel;
using SHJunketingBLL;
using System.Collections.Generic;

public partial class Admin_UserManagement_userManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            //绑定数据
            DataView ldvlist = new DataView();
            ldvlist.Table = C_UserLoginManager.GetAllUserLogin(string.Empty,string.Empty);
            AspNetPager1.RecordCount = ldvlist.Table.Rows.Count;
            Session["dvlist"] = ldvlist;
            Session["usreName"] = string.Empty;
            Session["LoginId"] = string.Empty;
            bindData();
        }
    }


    #region 数据绑定
    /// <summary>
    /// 数据绑定
    /// </summary>    
    void bindData()
    {
        PagedDataSource pds = new PagedDataSource();
        pds.AllowPaging = true;
        pds.PageSize = AspNetPager1.PageSize;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
        pds.DataSource = (DataView)Session["dvlist"];
        Repeater1.DataSource = pds;
        Repeater1.DataBind();
    }
    #endregion

    




    //根据用户名来查找
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        Web.CommFun.HasSqlInjectionChar(this);
        Session["usreName"] = tbsearch.Text.Trim();
        Session["LoginId"] = tbUserLogin.Text.Trim();

        DataView ldvlist = new DataView();
        ldvlist.Table = C_UserLoginManager.GetAllUserLogin(Session["usreName"].ToString(),Session["LoginId"].ToString());
        AspNetPager1.RecordCount = ldvlist.Table.Rows.Count;
        Session["dvlist"] = ldvlist;
        bindData();
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindData();
    }





    /// <summary>
    /// 获取用户角色
    /// </summary>
    /// <param name="roleId"></param>
    /// <returns></returns>
    public static string GetRoleName(int userId)
    {
        string name = "";
        List<string> list = C_UserRoleInfoManager.GetUsreLogin(userId);
        foreach (string names in list)
        {
            name += names + "　　";
        }
        return name;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddUser.aspx");
    }

    public string GetBookingStatus(string userId) 
    {
        return Web.DBHelper.GetBookingStatus(userId);
    }
}
